package com.alili_tv.system.mapper;

import com.alili_tv.system.entity.User;
import com.alili_tv.system.entity.Video;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 视频/合集表 Mapper 接口
 * </p>
 *
 * @author baomidou
 * @since 2023-03-17
 */
@Mapper
public interface VideoMapper extends BaseMapper<Video> {

    /**
     * 获取最近新动态的数量
     * @param userId
     * @return
     */
    boolean hasNew(long userId);

    /**
     * 获取动态视频
     * @param userId
     * @param pageIndex
     * @param pageSize
     * @return
     */
    List<Video> getDynamic(long userId, int pageIndex, int pageSize);

    /**
     * 获取推荐视频
     * @param count
     * @return
     */
    List<Video> getRecommend(@Param("count") Integer count, @Param("channelId") Integer channelId);

    /**
     * 通过ids获取视频, 并按照in得顺序排序
     * @param ids
     * @return
     */
    List<Video> getOrderByIn(Collection<Long> ids);

    /**
     * 通过ids获取视频
     * @param ids
     * @return
     */
    @MapKey("id")
    Map<Long, Video> getByIds(Collection<Long> ids);
}
